package com.sahyadri.web.bean;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import com.sahyadri.web.enums.OfferType;
import com.sahyadri.web.util.DateTimeUtil;

@Entity
@Table(name = "OFFER")
public class Offer implements Serializable{
	
	private static final long serialVersionUID = -924905248550666828L;

	@Id
	@GeneratedValue
	private long id;
	
	private String name;
	private String description;
	private Date startDate;
	private Date endDate;
	
	@Enumerated(EnumType.STRING)
	private OfferType offerType;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getStartDate() {
		return startDate;
	}
	
	public String getDisplayStartDate() {
		return DateTimeUtil.changeDateFormat(startDate, DateTimeUtil.DEFAULT_DATE_FORMAT);
	}
	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}
	
	public String getDisplayEndDate() {
		return DateTimeUtil.changeDateFormat(endDate, DateTimeUtil.DEFAULT_DATE_FORMAT);
	}
	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public OfferType getOfferType() {
		return offerType;
	}

	public void setOfferType(OfferType offerType) {
		this.offerType = offerType;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Offer other = (Offer) obj;
		if (id != other.id)
			return false;
		return true;
	}
	
	
}
